<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app1"></div>

  <script src="../js/react.development.js"></script>
  <script src="../js/react-dom.development.js"></script>
  <script src="../js/babel.min.js"></script>
  <script src="../js/prop-types.js"></script>

  <script type="text/babel">
    class Demo extends React.Component {

      myRef = React.createRef()

      showData = () => {
        let {myRef} = this
        alert(myRef.current.value)
      }
      showData2=(e)=>{
        console.log(e.target.value);
      }

      render() {
        return (
          <div>
            <input ref={this.myRef} type="text" placeholder="点击提示数据" />
            <button onClick={this.showData}>点我提示数据</button>
            <input onBlur={this.showData2} type="text" placeholder="点击提示数据" />

          </div>
        )
      }
    }

    ReactDOM.render(<Demo />, document.getElementById("app1"))
  </script>
</body>

</html>